// run: $exec < input
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

long long const mo = 1000000007;
long long k;

long long quick(long long a, long long b)
{
	if (!b) return 1;
	long long ret = quick(a, b / 2);
	ret = (ret * ret) % mo;
	if (b & 1) ret = (ret * a) % mo;
	return ret;
}
long long dp[100005];
long long dpdc[100005];
long long dpnc[100005];
long long dp2[100005];
long long dp2dc[100005];
long long dp2nc[100005];
int main()
{
	dp[1]=1;
	dpdc[1]=1;
	dpnc[1]=0;
	for(int i=2;i<=50000;i++)
	{
		dp[i]=1+dp[i-1]+(dp[i-1]+1)*dp[i-1]/2;
		dp[i]%=mo;
		dpdc[i]=dp[i-1]+1;
		dpdc[i]%=mo;

		dpnc[i]=dp[i]+mo-dpdc[i];
		dpnc[i]%=mo;
	}
	dp2[1]=1;
	dp2[2]=1;
	dp2dc[1]=1;
	dp2dc[2]=1;
	dp2nc[1]=0;
	dp2nc[2]=0;

	for(int i=3;i<=100000;i++)
	{
		if(i & 1)
		{
			dp2dc[i]=dp2dc[i-1]*(dpdc[i/2]+1);
			dp2dc[i]%=mo;

			dp2nc[i]=dp2dc[i-1]*(dpnc[i/2]);
			dp2nc[i]+=dp2nc[i-1]*(dp[i/2]+1);
			dp2nc[i]%=mo;
			dp2[i]=dp2nc[i]+dp2dc[i];
			dp2[i]%=mo;
		}
		else
		{
			dp2dc[i]=dp2dc[i-2]*dpdc[i/2];
			dp2dc[i]%=mo;
			dp2nc[i]=dp2nc[i-2]*dp[i/2];
			dp2nc[i]%=mo;
			dp2nc[i]+=dp2dc[i-2]*dpnc[i/2];
			dp2nc[i]%=mo;
			dp2[i]=dp2dc[i]+dp2nc[i];
			dp2[i]%=mo;
		}
	}
	std::ios::sync_with_stdio(false);
	while (std::cin >> k && k) {
		std::cout<<dp2[k]<<"\n";
	}
}

